package com.my12306.common.model.po;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
import java.util.Objects;

/**
 * @Author:苏牧夕
 * @Date:2020/5/27 23:05
 * @Version 1.0
 */
@TableName("schedule_job")
public class ScheduleJobPo implements Serializable {
    @TableId(value = "job_id")
    private Long jobId;
    /**
     * 任务名称
     */
    @TableField(value = "job_name")
    @NotNull(message = "任务名称不能为空")
    private String jobName;
    /**
     * cron 表达式
     */
    @TableField(value = "cron_expression")
    @NotNull(message = "cron表达式不能为空")
    private String cronExpression;
    /**
     * 负责执行工作的Bean名称
     */
    @TableField(value = "bean_name")
    @NotNull(message = "Bean名字不能为空")
    private String beanName;
    /**
     * 任务描述
     */
    @TableField(value = "job_desc")
    private String jobDesc;
    /**
     * 任务调度的状态：1.启动，2.暂停,3.删除
     */
    @TableField(value = "show_status")
    private Integer showStatus;
    /**
     * 任务类型：1.系统，2.用户
     */
    @TableField(value = "type")
    @NotNull(message = "任务类型不能为空")
    private Integer type;
    /**
     * 创建人id
     * 用户进行停止任务的时候可以查询相关的任务id
     */
    @TableField(value = "user_id")
    private Long userId;
    /**
     * 任务执行的数据
     */
    @TableField(value = "params")
    private String params;

    /**
     * 创建时间
     */
    private Date createDate;
    /**
     * 修改时间
     */
    private Date updateDate;

    public ScheduleJobPo() {
    }

    public ScheduleJobPo(Long jobId, @NotNull(message = "任务名称不能为空") String jobName, @NotNull(message = "cron表达式不能为空") String cronExpression, @NotNull(message = "Bean名字不能为空") String beanName, String jobDesc, Integer showStatus, @NotNull(message = "任务类型不能为空") Integer type, Long userId, String params, Date createDate, Date updateDate) {
        this.jobId = jobId;
        this.jobName = jobName;
        this.cronExpression = cronExpression;
        this.beanName = beanName;
        this.jobDesc = jobDesc;
        this.showStatus = showStatus;
        this.type = type;
        this.userId = userId;
        this.params = params;
        this.createDate = createDate;
        this.updateDate = updateDate;
    }

    @Override
    public String toString() {
        return "ScheduleJobPo{" +
                "jobId=" + jobId +
                ", jobName='" + jobName + '\'' +
                ", cronExpression='" + cronExpression + '\'' +
                ", beanName='" + beanName + '\'' +
                ", jobDesc='" + jobDesc + '\'' +
                ", showStatus=" + showStatus +
                ", type=" + type +
                ", userId=" + userId +
                ", params='" + params + '\'' +
                ", createDate=" + createDate +
                ", updateDate=" + updateDate +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof ScheduleJobPo)) return false;
        ScheduleJobPo that = (ScheduleJobPo) o;
        return Objects.equals(getJobId(), that.getJobId()) &&
                Objects.equals(getJobName(), that.getJobName()) &&
                Objects.equals(getCronExpression(), that.getCronExpression()) &&
                Objects.equals(getBeanName(), that.getBeanName()) &&
                Objects.equals(getJobDesc(), that.getJobDesc()) &&
                Objects.equals(getShowStatus(), that.getShowStatus()) &&
                Objects.equals(getType(), that.getType()) &&
                Objects.equals(getUserId(), that.getUserId()) &&
                Objects.equals(getParams(), that.getParams()) &&
                Objects.equals(getCreateDate(), that.getCreateDate()) &&
                Objects.equals(getUpdateDate(), that.getUpdateDate());
    }

    @Override
    public int hashCode() {
        return Objects.hash(getJobId(), getJobName(), getCronExpression(), getBeanName(), getJobDesc(), getShowStatus(), getType(), getUserId(), getParams(), getCreateDate(), getUpdateDate());
    }

    public Long getJobId() {
        return jobId;
    }

    public void setJobId(Long jobId) {
        this.jobId = jobId;
    }

    public String getJobName() {
        return jobName;
    }

    public void setJobName(String jobName) {
        this.jobName = jobName;
    }

    public String getCronExpression() {
        return cronExpression;
    }

    public void setCronExpression(String cronExpression) {
        this.cronExpression = cronExpression;
    }

    public String getBeanName() {
        return beanName;
    }

    public void setBeanName(String beanName) {
        this.beanName = beanName;
    }

    public String getJobDesc() {
        return jobDesc;
    }

    public void setJobDesc(String jobDesc) {
        this.jobDesc = jobDesc;
    }

    public Integer getShowStatus() {
        return showStatus;
    }

    public void setShowStatus(Integer showStatus) {
        this.showStatus = showStatus;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public String getParams() {
        return params;
    }

    public void setParams(String params) {
        this.params = params;
    }

    public Date getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    public Date getUpdateDate() {
        return updateDate;
    }

    public void setUpdateDate(Date updateDate) {
        this.updateDate = updateDate;
    }
}
